package com.hp.order_service.fallback;

import com.hp.order_service.entity.Goods;
import com.hp.order_service.feign.GoodsFeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * goods-service的调用的降级处理类
 */
@Component
public class GoodsFeignClientFallback implements GoodsFeignClient {

    @Override
    public ResponseEntity<Goods> getGoodsById(Long id) {
        return ResponseEntity.ok(new Goods(-1L,"降级数据",0.0));
    }

    @Override
    public ResponseEntity<String> saveGoods(Goods goods) {
        return ResponseEntity.ok("saveGoods降级");
    }

    @Override
    public ResponseEntity<String> updateGoods(Goods goods) {
        return ResponseEntity.ok("updateGoods降级");
    }

    @Override
    public ResponseEntity<String> deleteGoods(Long id) {
        return ResponseEntity.ok("deleteGoods降级");
    }

    @Override
    public ResponseEntity<List<Goods>> getAllGoods() {
        return ResponseEntity.ok(new ArrayList<>());
    }
}
